package cc.fs.kotlin.ui.demo

import android.Manifest
import android.content.Intent
import android.os.Bundle
import android.os.Message
import android.util.Log
import android.widget.Button
import cc.fs.kotlin.R
import cc.fs.kotlin.ui.activity.helper.BaseActivity
import cc.fs.kotlin.ui.activity.helper.RequestPermissionActivity
import cc.fs.kotlin.utils.bindView

/**
 * Created by fostion on 3/2/16.
 */
class PermissionDemo : BaseActivity() {

    val btn: Button by bindView(R.id.btn)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_demo_permission)

        btn.setOnClickListener {
            RequestPermissionActivity.requstPermission(this@PermissionDemo,Manifest.permission.CAMERA,object : RequestPermissionActivity.RequestionPermissionCallback{
                override fun onPermissionCallback(result: Boolean) {
                    if(result){
                        showToast("获得权限成功")
                    } else {
                        showToast("获取权限失败")
                    }
                }
            })
        }
    }

    override fun handler(msg: Message) {

    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
    }

}